﻿using MediatR;
using SystemLYH.API.Application.Command.ProcuredCommand;
using SystemLYH.Domain;
using SystemLYH.Infrstructre.Interface;

namespace SystemLYH.API.Application.Handlers.ProcuredHandlers
{
	public class ProcuredUpdateHandlers : IRequestHandler<ProcuredUpdateCommand, int>
	{
		protected readonly IProcuredrequestRepository _procuredrequestRepository;
		/// <summary>
		/// 采购申请构造函数
		/// </summary>
		/// <param name="procuredrequestRepository"></param>
		public ProcuredUpdateHandlers(IProcuredrequestRepository procuredrequestRepository)
		{
			_procuredrequestRepository = procuredrequestRepository;
		}
		public async Task<int> Handle(ProcuredUpdateCommand request, CancellationToken cancellationToken)
		{
			return await _procuredrequestRepository.UpdateAsync(new Procuredrequest()
			{
				ProcuredId = request.ProcuredId,
				ProcuredNumber = request.ProcuredNumber,
				FeedstockNumber = request.FeedstockNumber,
				FeedstockName = request.FeedstockName,
				FeedstockNum = request.FeedstockNum,
				Feedstocktype = request.Feedstocktype,
				FeedstockSize = request.FeedstockSize,
				ProcuredBudget = request.ProcuredBudget,
				LotNumber = request.LotNumber,
				ProcuredState = request.ProcuredState,
				ProcessPrice = request.ProcessPrice,
				ProcessActual = request.ProcessActual,
				PayMethods = request.PayMethods,
				supplierID = request.supplierID,
				AddName = request.AddName,
				AddTime = request.AddTime.Value.ToUniversalTime(),
			});
		}
	}
}
